<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<script>
			document.addEventListener('keydown',fun1);
			function fun1(e){
				var k = e.key;
				var c = e.code;
				if(k=='a'||k=='A'){
					alert("现在按得是A或者a");
				}
				document.body.innerHTML = "现在按的是:" + k;
				console.log("key:"+k+",code:"+c);
			}
		</script>
	</body>
</html>